﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RegisterPanel : MonoBehaviour {
    public InputField username;
    public InputField nickname;
    public InputField password;
    public Button regisBtn;
   public GameObject login;
    // Use this for initialization
    void Start () {
        regisBtn.onClick.AddListener(OnRegisClick);       
	} 
    void OnRegisClick()
    {
        Data.ReqRegister req = new Data.ReqRegister();
        req.username = username.text;
        req.nickname = nickname.text;
        req.password = password.text;

        NetworkManager.Instance.Send(Protocal.Register_CMD,ProtoHelper.Serialize(req));
    }
    void OnRegisterResponse(Data.ReqRegister rep)
    {
        if (rep.errorCode.code==1)
        {
            Debug.Log(rep.nickname + "注册完成");
            //切换登陆界面
            this.gameObject.SetActive(false);
            login.SetActive(true);
        }
        else
        {
            Debug.Log(rep.errorCode.error);
        }
    }
}
